package com.atguigu.common.utils;

import org.springframework.validation.BindingResult;

import java.util.HashMap;
import java.util.Map;

public class FieldErrorMap {
    public static Map<String,String> getFieldErrorMap(BindingResult result){
        HashMap<String, String> map = new HashMap<>();
        if(result.hasErrors()){
            result.getFieldErrors().forEach((item)->{
                map.put(item.getField(),item.getDefaultMessage());
            });
        }
        return map;
    }
}
